<template>
  <div>
    <el-tabs v-model="activeName">
      <template v-for="(item,index) in newTabs">
        <el-tab-pane :key="index" :label="item.label" :name="item.name" v-permission="item.isPermission">
          <component :is="item.component" v-permission="item.isPermission"></component>
        </el-tab-pane>
      </template>
    </el-tabs>
  </div>
</template>

<script>
import CaseApproval from './components/CaseApproval'
import CaseManage from './components/CaseManage'
import CaseDispatch from './components/CaseDispatch'
import { filterPermissionTebs } from '@/utils/util.js'
export default {
  components: { CaseApproval, CaseManage, CaseDispatch },
  data () {
    return {
      activeName: 'caseApproval',
      tabList: [
        { label: '进件审批', component: 'CaseApproval', name: 'caseApproval', refs: 'caseApproval', isPermission: 'INCOMING_APPROVAL' },
        { label: '进件管理', component: 'CaseManage', name: 'caseManage', refs: 'caseManage', isPermission: 'INCOMING_MANAGEMENT' },
        { label: '进件分派', component: 'CaseDispatch', name: 'caseDispatch', refs: 'caseDispatch', isPermission: 'INCOMING_DISPATCH' }
      ],
      newTabs: []
    }
  },
  mounted () {
    this.$nextTick(() => {
      this.init()
    })
  },
  methods: {
    init () {
      let res = filterPermissionTebs(this.tabList)
      this.newTabs = [...res.newTabs]
      this.activeName = res.activeName
    }
  }
}
</script>
